package tools;

import android.app.Activity;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

/**
 * 网络判断
 */
public class IsInternet {
    private static class SingletonHolder {

        private static IsInternet instance = new IsInternet();
    }
    public static IsInternet getInstance() {
        return SingletonHolder.instance;
    }

    public static boolean isNetworkAvailable(Context context)
    {// 判断网络连接状态
        if (context != null) {
            ConnectivityManager mConnectivityManager = (ConnectivityManager) context
                    .getSystemService(Context.CONNECTIVITY_SERVICE);
            NetworkInfo mNetworkInfo = mConnectivityManager
                    .getActiveNetworkInfo();
            if (mNetworkInfo != null) {
                return mNetworkInfo.isAvailable();
            }
        }
        return false;
    }

}
